package views;

import views.panels.PanelGeneral;
import logicBusiness.ProfesorBL;
import models.Profesor;
import java.awt.BorderLayout;
import java.util.Calendar;
import java.util.Collection;
import java.util.Iterator;
import java.util.StringTokenizer;

/**
 *
 * @author JARR
 */
public class InterfazAdministrarProfesor extends javax.swing.JFrame {

    private boolean consulta;
    private String[] docProf;

    /** Creates new form InterfazAdministrarProfesor */
    public InterfazAdministrarProfesor() {
        initComponents();
        PanelGeneral panel = new PanelGeneral();
        this.add(panel, BorderLayout.SOUTH);
        Calendar fechaAct = Calendar.getInstance();
        int añadir = fechaAct.get(Calendar.YEAR) - 2009;
        if (añadir > 0) {
            for (int i = 0; i < añadir; i++) {
                CBAño.addItem(String.valueOf(2009 + i + 1));

            }
        }
        CBSeleccionar.setEnabled(false);
        BCrearProfesor.setEnabled(false);
        BActualizarProfesor.setEnabled(false);


    }

    public void calcularEdad() {
        Calendar fechaAct = Calendar.getInstance(),
                fechaNac = Calendar.getInstance();
        int edad;

        if (CBDia.getSelectedIndex() == 0 || CBMes.getSelectedIndex() == 0 || CBAño.getSelectedIndex() == 0) {
            jTextField2.setText("--");
        } else {
            int dia = Integer.parseInt((String) CBDia.getSelectedItem()),
                    mes = CBMes.getSelectedIndex(),
                    año = Integer.parseInt((String) CBAño.getSelectedItem());

            fechaNac.set(fechaAct.get(Calendar.YEAR), mes - 1, dia);//año actual con dia y mes de nacimiento el mes es en base 0(mayo es 4)
            if (fechaAct.getTime().before(fechaNac.getTime())) {//descubriendo si el dia de hoy es despues del dia cumpleaños
                edad = fechaAct.get(Calendar.YEAR) - año - 1;
            } else {
                edad = fechaAct.get(Calendar.YEAR) - año;
            }
            jTextField2.setText(String.valueOf(edad));
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        CTEspecialidad = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        CTUsuarioProfesor = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        CTTelFijo = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        CTTelMovil = new javax.swing.JTextField();
        CTDireccion = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        CTDNIProfesor = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        CTNomProfesor = new javax.swing.JTextField();
        CTApelliProfesor = new javax.swing.JTextField();
        BCrearProfesor = new javax.swing.JButton();
        CBDia = new javax.swing.JComboBox();
        CBMes = new javax.swing.JComboBox();
        CBAño = new javax.swing.JComboBox();
        CBSexo = new javax.swing.JComboBox();
        jSeparator1 = new javax.swing.JSeparator();
        RBNomUsuario = new javax.swing.JRadioButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        BActualizarProfesor = new javax.swing.JButton();
        CBSeleccionar = new javax.swing.JComboBox();
        RBCrearProfesor = new javax.swing.JRadioButton();
        RBActualizarProfesor = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Crear Profesor");
        setResizable(false);

        jLabel4.setText("Especialidad:");

        jLabel5.setText("Género:");

        CTUsuarioProfesor.setEditable(false);

        jLabel6.setText("Teléfono Fijo:");

        jLabel8.setText("Dirección:");

        jLabel3.setText("Edad:");

        jTextField2.setEditable(false);

        jLabel2.setText("Documento de Identificación:");

        jLabel9.setText("Fecha de Nacimiento:");

        jLabel7.setText("Teléfono Móvil:");

        jLabel1.setText("Nombre del Profesor:");

        jLabel11.setText("Apellidos del Profesor:");

        BCrearProfesor.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        BCrearProfesor.setText("Crear Profesor");
        BCrearProfesor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCrearProfesorActionPerformed(evt);
            }
        });

        CBDia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Dia", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        CBDia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBDiaActionPerformed(evt);
            }
        });

        CBMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mes", "ENERO", "FEBRERO", "MARZO", "ABRIL", "MAYO", "JUNIO", "JULIO", "AGOSTO", "SEPTIEMBRE", "OCTUBRE", "NOVIEMBRE ", "DICIEMBRE" }));
        CBMes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBMesActionPerformed(evt);
            }
        });

        CBAño.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Año", "1900", "1901", "1902", "1903", "1904", "1905", "1906", "1907", "1908", "1909", "1910", "1911", "1912", "1913", "1914", "1915", "1916", "1917", "1918", "1919", "1920", "1921", "1922", "1923", "1924", "1925", "1926", "1927", "1928", "1929", "1930", "1931", "1932", "1933", "1934", "1935", "1936", "1937", "1938", "1939", "1940", "1941", "1942", "1943", "1944", "1945", "1946", "1947", "1948", "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956", "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009" }));
        CBAño.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBAñoActionPerformed(evt);
            }
        });

        CBSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione:", "FEMENINO\t", "MASCULINO" }));

        RBNomUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBNomUsuarioActionPerformed(evt);
            }
        });

        jLabel10.setText("Nombre de Usuario");

        jLabel12.setText("Si no selecciona el botón no se creará el nombre de usuario!");

        jLabel13.setText("La creación y asignación de usuarios tambien la podrá hacer desde la");

        jLabel14.setText("ventana destinada para esa tarea.");

        BActualizarProfesor.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        BActualizarProfesor.setText("Actualizar Profesor");
        BActualizarProfesor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BActualizarProfesorActionPerformed(evt);
            }
        });

        CBSeleccionar.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione" }));
        CBSeleccionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CBSeleccionarActionPerformed(evt);
            }
        });

        RBCrearProfesor.setBackground(new java.awt.Color(118, 104, 230));
        RBCrearProfesor.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        RBCrearProfesor.setText("CREAR PROFESOR");
        RBCrearProfesor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBCrearProfesorActionPerformed(evt);
            }
        });

        RBActualizarProfesor.setBackground(new java.awt.Color(118, 104, 230));
        RBActualizarProfesor.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        RBActualizarProfesor.setText("ACTUALIZAR O CONSULTAR PROFESOR");
        RBActualizarProfesor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBActualizarProfesorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel11)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(RBNomUsuario)
                                        .addGap(18, 18, 18)
                                        .addComponent(CTUsuarioProfesor))
                                    .addComponent(CTNomProfesor)
                                    .addComponent(CTApelliProfesor)
                                    .addComponent(CTDNIProfesor)
                                    .addComponent(CTEspecialidad)
                                    .addComponent(CTTelFijo)
                                    .addComponent(CTTelMovil)
                                    .addComponent(CTDireccion)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                                .addComponent(CBSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jLabel3))
                                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                                .addComponent(CBDia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(CBMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(18, 18, 18)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(CBAño, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(BCrearProfesor)
                        .addGap(57, 57, 57)
                        .addComponent(BActualizarProfesor))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(CBSeleccionar, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(RBCrearProfesor)
                            .addGap(18, 18, 18)
                            .addComponent(RBActualizarProfesor))))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {CBAño, jTextField2});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {BActualizarProfesor, BCrearProfesor});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(RBCrearProfesor)
                    .addComponent(RBActualizarProfesor))
                .addGap(9, 9, 9)
                .addComponent(CBSeleccionar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(CTNomProfesor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(CTApelliProfesor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(CTDNIProfesor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(CTEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(CTTelFijo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(CTTelMovil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(CTDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(CBDia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CBMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CBAño, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(CBSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(RBNomUsuario)
                    .addComponent(CTUsuarioProfesor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE)
                .addGap(4, 4, 4)
                .addComponent(jLabel13)
                .addGap(4, 4, 4)
                .addComponent(jLabel14)
                .addGap(11, 11, 11)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BActualizarProfesor)
                    .addComponent(BCrearProfesor))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BCrearProfesorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BCrearProfesorActionPerformed
        String fechaNac = (String) CBDia.getSelectedItem() + "-" + String.valueOf(CBMes.getSelectedIndex()) + "-" + (String) CBAño.getSelectedItem();
        String usuario;
        if (RBNomUsuario.isSelected()) {
            usuario = CTUsuarioProfesor.getText();
        } else {
            usuario = null;
        }
        ProfesorBL bo = new ProfesorBL();
//        Profesor p = bo.crearProfesor(CTNomProfesor.getText(),
//                CTApelliProfesor.getText(), Long.parseLong(CTDNIProfesor.getText()),
//                CTEspecialidad.getText(), CTTelFijo.getText(),
//                CTTelMovil.getText(), CTDireccion.getText(),
//                fechaNac, (String) CBSexo.getSelectedItem(), Integer.parseInt(jTextField2.getText()), usuario);
        consulta = false;
    }//GEN-LAST:event_BCrearProfesorActionPerformed

    private void CBDiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBDiaActionPerformed
        calcularEdad();
    }//GEN-LAST:event_CBDiaActionPerformed

    private void CBMesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBMesActionPerformed
        calcularEdad();
    }//GEN-LAST:event_CBMesActionPerformed

    private void CBAñoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBAñoActionPerformed
        calcularEdad();
    }//GEN-LAST:event_CBAñoActionPerformed

    private void RBNomUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBNomUsuarioActionPerformed
        if (RBNomUsuario.isSelected()) {
            CTUsuarioProfesor.setEditable(true);
        } else {
            CTUsuarioProfesor.setEditable(false);
        }
    }//GEN-LAST:event_RBNomUsuarioActionPerformed

    private void RBActualizarProfesorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBActualizarProfesorActionPerformed
        RBActualizarProfesor.setSelected(true);
        BActualizarProfesor.setEnabled(true);
        BCrearProfesor.setEnabled(false);
        RBCrearProfesor.setSelected(false);
        CBSeleccionar.setEnabled(true);
        consultarProfesores();
    }//GEN-LAST:event_RBActualizarProfesorActionPerformed

    private void RBCrearProfesorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBCrearProfesorActionPerformed
        RBCrearProfesor.setSelected(true);
        BCrearProfesor.setEnabled(true);
        BActualizarProfesor.setEnabled(false);
        RBActualizarProfesor.setSelected(false);
        CBSeleccionar.setEnabled(false);
    }//GEN-LAST:event_RBCrearProfesorActionPerformed

    private void CBSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CBSeleccionarActionPerformed
        ProfesorBL bo = new ProfesorBL();
//        Profesor p = bo.encontrarProfesor(Long.valueOf(docProf[CBSeleccionar.getSelectedIndex()]));
//        CTNomProfesor.setText(p.getNombreProfesor());
//        CTApelliProfesor.setText(p.getApellidoProfesor());
//        CTDNIProfesor.setText(String.valueOf(p.getDocProfesor()));
        CTDNIProfesor.setEditable(false);
//        CTEspecialidad.setText(p.getEspecialidad());
//        CTTelFijo.setText(p.getTelFijo());
//        CTTelMovil.setText(p.getTelMovil());
//        CTDireccion.setText(p.getDireccionProf());
//        StringTokenizer token = new StringTokenizer(p.getFechaNacimientoProf(), "-");
//        CBDia.setSelectedIndex(Integer.valueOf(token.nextToken()));
//        CBMes.setSelectedIndex(Integer.valueOf(token.nextToken()));
//        CBAño.setSelectedIndex(Integer.valueOf(token.nextToken()) - 1899);
//        CBSexo.setSelectedItem(p.getGeneroProf());
//        jTextField2.setText(String.valueOf(p.getEdadProf()));
        CTUsuarioProfesor.setEditable(true);
//        CTUsuarioProfesor.setText(p.getNombreUsuario());
        CTUsuarioProfesor.setEditable(false);

    }//GEN-LAST:event_CBSeleccionarActionPerformed

    private void BActualizarProfesorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BActualizarProfesorActionPerformed
        String fechaNac = (String) CBDia.getSelectedItem() + "-" + String.valueOf(CBMes.getSelectedIndex()) + "-" + (String) CBAño.getSelectedItem();
        ProfesorBL bo = new ProfesorBL();
//        Profesor p = bo.actualizarProfesor(Long.valueOf(docProf[CBSeleccionar.getSelectedIndex()]), CTNomProfesor.getText(),
//                CTApelliProfesor.getText(), null,//el doc no es actualizable
//                CTEspecialidad.getText(), CTTelFijo.getText(),
//                CTTelMovil.getText(), CTDireccion.getText(),
//                fechaNac, (String) CBSexo.getSelectedItem(),
//                Integer.parseInt(jTextField2.getText()), null);//no se actualizan usuarios

    }//GEN-LAST:event_BActualizarProfesorActionPerformed
    private void consultarProfesores() {
        if (consulta == false) {
            CBSeleccionar.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Seleccione"}));
            String nombreProf = "", toStringProf;
            ProfesorBL bo = new ProfesorBL();
//            Collection<Profesor> p = bo.encontrarProfesores();
//            docProf = new String[p.size() + 1];
            docProf[0] = "default0";
//            Iterator<Profesor> it = p.iterator();
            int i = 1, numToken;
//            while (it.hasNext()) {
//                numToken = 1;
//                nombreProf = "";
//                toStringProf = it.next().toString();
//                StringTokenizer token = new StringTokenizer(toStringProf);
//                while (token.hasMoreTokens()) {//mientras el tostrin de profesor tiene mas palabras
//                    if (numToken == 1) {// si es el token 1, yo se que es el documento
//                        docProf[i] = "" + token.nextToken();
//                    } else {// si no, yo se que viene el nombre y el apellido
//                        nombreProf += token.nextToken() + " ";
//                    }
//                    numToken++;
//                }
//                CBSeleccionar.addItem(nombreProf + " Doc: " + docProf[i]);
//                i++;
//            }
            consulta = true;
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new InterfazAdministrarProfesor().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BActualizarProfesor;
    private javax.swing.JButton BCrearProfesor;
    private javax.swing.JComboBox CBAño;
    private javax.swing.JComboBox CBDia;
    private javax.swing.JComboBox CBMes;
    private javax.swing.JComboBox CBSeleccionar;
    private javax.swing.JComboBox CBSexo;
    private javax.swing.JTextField CTApelliProfesor;
    private javax.swing.JTextField CTDNIProfesor;
    private javax.swing.JTextField CTDireccion;
    private javax.swing.JTextField CTEspecialidad;
    private javax.swing.JTextField CTNomProfesor;
    private javax.swing.JTextField CTTelFijo;
    private javax.swing.JTextField CTTelMovil;
    private javax.swing.JTextField CTUsuarioProfesor;
    private javax.swing.JRadioButton RBActualizarProfesor;
    private javax.swing.JRadioButton RBCrearProfesor;
    private javax.swing.JRadioButton RBNomUsuario;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration//GEN-END:variables
}
